package com.cyanite.playlv2api.types;

import com.cyanite.playlv2api.util.ParcelUtils;

import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

public class Trip implements PlayLv2Type, Parcelable {

	private String mId;
    private String mName;
    private String mUserId;
    private String mUserName;
    private String mUserPhoto;
    private Group<User> mFriendsInCommon;
    private String mPhoto;
    private Bitmap mPhotoBmp;
	private String mStartpoint;
	private String mEndpoint;
	private String mStartDate;
	private String mDays;
	private int mProcess;
	private int  mCategoryId;
	private int mCheckinsCount;
	private int mTasksCount;
	private int mFocusedCount;
	private long mUpdateTime;
    private boolean mIsFocused;
    private Group<TripMini> mTripsRecommend;


    public Trip() {
        mIsFocused = false;
    }

    private Trip(Parcel in) {
        mId = ParcelUtils.readStringFromParcel(in);
    	mName = ParcelUtils.readStringFromParcel(in);
        mUserId = ParcelUtils.readStringFromParcel(in);
        mUserName = ParcelUtils.readStringFromParcel(in);
        mUserPhoto = ParcelUtils.readStringFromParcel(in);
        mPhoto = ParcelUtils.readStringFromParcel(in);
        mCategoryId = Integer.valueOf(ParcelUtils.readStringFromParcel(in));
        mProcess =  Integer.valueOf(ParcelUtils.readStringFromParcel(in));
        mIsFocused =  Boolean.valueOf(ParcelUtils.readStringFromParcel(in));
        
        
        int numFriendsinCommon = in.readInt();
        if(numFriendsinCommon > 0){
            mFriendsInCommon = new Group<User>();
            for (int i = 0; i < numFriendsinCommon; i++) {
                User user = in.readParcelable(User.class.getClassLoader());
                mFriendsInCommon.add(user);
            }
        }
        
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        ParcelUtils.writeStringToParcel(out, mId);
        ParcelUtils.writeStringToParcel(out, mName);
        ParcelUtils.writeStringToParcel(out, mUserId);
        ParcelUtils.writeStringToParcel(out, mUserName);
        ParcelUtils.writeStringToParcel(out, mUserPhoto);
        ParcelUtils.writeStringToParcel(out, mPhoto);
        ParcelUtils.writeStringToParcel(out, String.valueOf(mCategoryId));
        ParcelUtils.writeStringToParcel(out, String.valueOf(mProcess));
        ParcelUtils.writeStringToParcel(out, String.valueOf(mIsFocused));
        
        if (mFriendsInCommon != null) {
            out.writeInt(mFriendsInCommon.size());
            for (int i = 0; i < mFriendsInCommon.size(); i++) {
                out.writeParcelable(mFriendsInCommon.get(i), flags);
            }
        } else {
            out.writeInt(0);
        }
    }

    public static final Parcelable.Creator<Trip> CREATOR = new Parcelable.Creator<Trip>() {
        public Trip createFromParcel(Parcel in) {
            return new Trip(in);
        }

        @Override
        public Trip[] newArray(int size) {
            return new Trip[size];
        }
    };

    public Group<TripMini> getTripsRecommend() {
        return mTripsRecommend;
    }

    public void setTripsRecommend(Group<TripMini> trips) {
        mTripsRecommend = trips;
    }

    public Group<User> getFriendsInCommon() {
        return mFriendsInCommon;
    }

    public void setFriendsInCommon(Group<User> friends) {
        mFriendsInCommon = friends;
    }

    public boolean isFocused() {
        return mIsFocused;
    }

    public void setFocused(boolean isFocused) {
        mIsFocused = isFocused;
    }

    public String getUserName() {
        return mUserName;
    }

    public void setUserName(String username) {
        mUserName = username;
    }

    public String getUserId()  {
        return mUserId;
    }

    public void setUserId(String userId)  {
        mUserId = userId;
    }

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        mName = name;
    }

    public String getId() {
        return mId;
    }

    public void setId(String tripId) {
        mId = tripId;
    }

    public String getPhoto() {
        return mPhoto;
    }

    public void setPhoto(String photo) {
        mPhoto = photo;
    }

    public void setPhotoBitmap(Bitmap photo) {
        mPhotoBmp = photo;
    }

    public Bitmap getPhotoBitmap()   {
        return mPhotoBmp;
    }

    public String getUserPhoto() {
        return mUserPhoto;
    }

    public void setUserPhoto(String photo) {
        mUserPhoto = photo;
    }

    public int getProcess() {
        return mProcess;
    }

    public void setProcess(int process) {
        mProcess = process;
    }

    public int getFocusedCount() {
        return mFocusedCount;
    }

    public void setFocusedCount(int count) {
        mFocusedCount = count;
    }

    public long getUpdateTime() {
        return mUpdateTime;
    }

    public void setUpdateTime(long time)    {
        mUpdateTime = time;
    }

    public int getCheckinsCount() {
        return mCheckinsCount;
    }

    public void setCheckinsCount(int count) {
        mCheckinsCount = count;
    }
    
    public int getTasksCount() {
        return mTasksCount;
    }

    public void setTasksCount(int count) {
        mTasksCount = count;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public void setStartpoint(String startpoint)   {
		mStartpoint = startpoint;
	}

	public String getStartpoint()  {
		return mStartpoint;
	}

	public void setEndpoint(String endpoint)   {
		mEndpoint = endpoint;
	}

	public String getEndpoint()    {
		return mEndpoint;
	}

	public void setStartDate(String date)   {
		mStartDate = date;
	}

	public String getStartDate()    {
		return mStartDate;
	}

	public void setTotalDays(String date)   {
	    mDays = date;
    }

    public String getTotalDays()    {
        return mDays;
    }

	public void setCategoryId( int categoryId )    {
	    mCategoryId = categoryId;
	}

	public int getCategoryId()   {
		return mCategoryId;
	}

    public void reset() {
    }
}
